-
Notifications
You must be signed in to change notification settings - Fork 57
fix: Encode a01 values as json strings #645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes the A01 protocol encoding to match the old API behavior by encoding all values as JSON strings. Previously, values were passed through as-is; now they are wrapped with json.dumps() to ensure protocol compatibility.
- Applied
json.dumps()to all values in the dps dictionary withinencode_mqtt_payload() - Updated existing tests to expect JSON-stringified values
- Added a new test to verify list values are properly encoded as strings
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| roborock/protocols/a01_protocol.py | Modified encode_mqtt_payload() to apply json.dumps() to all values, converting them to JSON strings before encoding |
| tests/protocols/test_a01_protocol.py | Updated test expectations to reflect JSON string encoding, added imports for manual payload decoding, and added new test case for list conversion |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Test are failing |
|
I want to come back to this with better tests |
Update the a01 internal values to be json strings inside the dictionary. This matches the old API behavior.
5e95ed7 to
89f0109
Compare
allenporter
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, tests are not updated to catch the bug.
(The original change added double encoding to the old API and the encoding was not tested)
The bug was introduced in Python-roborock#645. Add tests that exercise the actual request encoding. This changes the ID QUERY value encoding by passing in a function, which is another variation on the first version of Python-roborock#645 where the json encoding happened inside the decode function.
* fix: Fix exception when sending dyad/zeo requests The bug was introduced in #645. Add tests that exercise the actual request encoding. This changes the ID QUERY value encoding by passing in a function, which is another variation on the first version of #645 where the json encoding happened inside the decode function. * chore: fix tests to be focused on value encoder * chore: fix lint
Update the a01 internal values to be json strings inside the dictionary. This matches the old API behavior.
Issue #623